﻿<controls:ChildWindow xmlns:Candy="clr-namespace:Candy"  
                      x:Class="Candy.RegistrationWindow"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
           Title="RegistrationWindow"
                      Style="{StaticResource ChildWindowStyleChromeless}"
                      DataContext="{Binding Source={StaticResource Locator}, Path=Registration}">
    <Border  Margin="0" BorderBrush="{StaticResource Accent}"  BorderThickness="1" Width="500" Height="350" Background="{StaticResource ControlBackgroundDark}">

        <Grid x:Name="LayoutRoot"  >
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="121*" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="145*" />
            </Grid.RowDefinitions>
            <TextBlock Grid.Column="1" Grid.Row="2" x:Name="textBlock1" Text="Username" VerticalAlignment="Center"  />
            <TextBlock x:Name="textBlock2" Text="Password" Grid.Column="1" Grid.Row="4" VerticalAlignment="Center"  />
            <TextBlock x:Name="textBlock3" Text="Password repeat" Grid.Column="1" Grid.Row="5" VerticalAlignment="Center" Margin="0,0,4,0"    />
            <TextBlock x:Name="textBlock4" Text="E-mail" Grid.Column="1" Grid.Row="3" VerticalAlignment="Center"   />
            <TextBox Text="{Binding RegData.UserName, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Column="2" Grid.Row="2" x:Name="textBox1" VerticalAlignment="Center" Margin="4,4,0,4" />
            <TextBox Text="{Binding RegData.Email, Mode=TwoWay, ValidatesOnDataErrors=True}" x:Name="textBox2" Grid.Column="2" Grid.Row="3" VerticalAlignment="Center" Margin="4,4,0,4"  />
            <PasswordBox Password="{Binding RegData.Password, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Column="2" Grid.Row="4" x:Name="passwordBox" VerticalAlignment="Center" Margin="4,4,0,4" />
            <PasswordBox  Password="{Binding RegData.PasswordConfirmation, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Column="2" Grid.Row="5" x:Name="passwordConfirmBox" VerticalAlignment="Center" Margin="4,4,0,4"  />
            <Button Click="button1_Click" Command="{Binding Register}"  Content="Register" ToolTipService.ToolTip="Register user and login." Grid.Column="2" Grid.Row="6" HorizontalAlignment="Right" Margin="0,4,85,0" x:Name="button1" VerticalAlignment="Top" Width="75"  />
            <TextBlock Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" Margin="0,0,0,2" x:Name="textBlock5" Text="Profile picture" VerticalAlignment="Bottom"  />
            <Grid Grid.Column="2" Grid.Row="1" HorizontalAlignment="Stretch" Margin="4,0,0,2" x:Name="grid1" VerticalAlignment="Center">
                <Grid.RowDefinitions>
                    <RowDefinition Height="22*" />
                    <RowDefinition Height="22*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="86*" />
                </Grid.ColumnDefinitions>
                <Image AllowDrop="True" Drop="avatarImage_Drop" HorizontalAlignment="Center" x:Name="avatarImage" Stretch="UniformToFill" VerticalAlignment="Center" Source="{Binding RegData.ProfilePicture, Converter={StaticResource BitmapToJpgConverter}, Mode=TwoWay}" Grid.RowSpan="2" Width="112" Margin="0,0,8,0" />
                <Button Content="Open" ToolTipService.ToolTip="Open an existing picture from your hard drive." Grid.Column="1" Grid.Row="1" HorizontalAlignment="Right" Margin="0,0,54,0" x:Name="buttonOpenFile" VerticalAlignment="Bottom" Click="buttonOpenFile_Click"/>
                <Button Content="Take" ToolTipService.ToolTip="Take a picture from your webcam." Margin="0" x:Name="buttonWebcam" VerticalAlignment="Bottom" Grid.Column="1" Click="buttonWebcam_Click" Grid.Row="1" HorizontalAlignment="Right"  />
            </Grid>
            <Button Content="Cancel" Command="{Binding Cancel}" Grid.Column="2" Grid.Row="6" HorizontalAlignment="Right" Margin="146,4,0,0" x:Name="button2" VerticalAlignment="Top" Width="75"  />
            <ProgressBar Grid.ColumnSpan="4" Margin="0" VerticalAlignment="Top" IsIndeterminate="True" Visibility="{Binding IsBusy, Converter={StaticResource VisibilityConverter}, Mode=OneWay}"/>
        </Grid>
    </Border>
</controls:ChildWindow>